package com.mtr.databoard.domain.screens;

import com.mtr.databoard.domain.Entity;
import com.mtr.databoard.domain.middlewares.Middleware;

import java.util.UUID;

public class ScreenComponent extends Entity<UUID> implements Cloneable {
    private ScreenViewComponent view;
    private ScreenMiddleware middleware;

    private int order;
    private Position position;
    private boolean isShow;
    private String name;
    private String code;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public ScreenViewComponent getView() {
        return view;
    }

    public void setView(ScreenViewComponent view) {
        this.view = view;
    }

    public ScreenMiddleware getMiddleware() {
        return middleware;
    }

    public void setMiddleware(ScreenMiddleware middleware) {
        this.middleware = middleware;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public Position getPosition() {
        return position;
    }

    public void setPosition(Position position) {
        this.position = position;
    }

    public boolean isShow() {
        return isShow;
    }

    public void setShow(boolean show) {
        isShow = show;
    }

    public ScreenComponent() {
    }

    public ScreenComponent(ScreenViewComponent view) {
        this.view = view;
        this.setId(UUID.randomUUID());
    }

    public ScreenComponent(ScreenViewComponent view, ScreenMiddleware middleware, int order, Position position, boolean isShow) {
        this.view = view;
        this.middleware = middleware;
        this.order = order;
        this.position = position;
        this.isShow = isShow;
        this.setId(UUID.randomUUID());
    }

    /**
     * 复制
     * @return
     * @throws CloneNotSupportedException
     */
    public ScreenComponent copy() throws CloneNotSupportedException {
        ScreenComponent component=(ScreenComponent)this.clone();
        component.setId(UUID.randomUUID());
        return component;
    }

}
